package com.zuo.seckilldemo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zuo.seckilldemo.entity.Order;
import com.zuo.seckilldemo.entity.OrderInfo;
import com.zuo.seckilldemo.mapper.OrderInfoMapper;
import com.zuo.seckilldemo.mapper.OrderMapper;
import com.zuo.seckilldemo.service.GoodsService;
import com.zuo.seckilldemo.service.OrderService;
import com.zuo.seckilldemo.vo.GoodsVo;
import com.zuo.seckilldemo.vo.OrderDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zuogaocan
 * @since 2023-01-31
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
    
    @Autowired
    private OrderInfoMapper orderInfoMapper;
    
    @Autowired
    private GoodsService goodsService;
    @Override
    public OrderDetailVo detail(Long orderId) {

        LambdaQueryWrapper<OrderInfo> wrapper1 = new LambdaQueryWrapper<>();
        wrapper1.eq(OrderInfo::getId,orderId);
        OrderInfo orderInfo = orderInfoMapper.selectOne(wrapper1);
        Long goodsId = orderInfo.getGoodsId();
        OrderDetailVo orderDetailVo = new OrderDetailVo();
        orderDetailVo.setOrderInfo(orderInfo);
        GoodsVo goodsVoByGoodsId = goodsService.findGoodsVoByGoodsId(goodsId);
        orderDetailVo.setGoodsVo(goodsVoByGoodsId);
        return orderDetailVo;
    }
}
